package chapter12.demo_1_;

import java.util.ArrayList;
import java.util.List;

import static com.common.utils.Print.*;

public class ForNameCreator extends PetCreator {
    private static List<Class<? extends Pet>> types = new ArrayList<>();

    private static String[] typeNames = {
            "chapter12.demo_1_.Mutt",
            "chapter12.demo_1_.Pug",
            "chapter12.demo_1_.EgyptianMau",
            "chapter12.demo_1_.Manx",
            "chapter12.demo_1_.Cymric",
            "chapter12.demo_1_.Rat",
            "chapter12.demo_1_.Mouse",
            "chapter12.demo_1_.Hamster",
    };

    static {
        load();
    }

    private static void load() {
        try {
            for (String string : typeNames) {
                types.add((Class<? extends Pet>) Class.forName(string));
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }

    }


    @Override
    public List<Class<? extends Pet>> types() {
        return types;
    }

}
